import requests

from api.ihrm_login_api import IHRMLoginApi
from common.assert_util import AssertUtil


class IHRMManageEmpApi:

    # 定义添加员工的接口
    @classmethod
    def add_emp_api(cls,token,data): # 变量的数据 设置成参数,在测试对象层进行传参
        url = "http://ihrm-test.itheima.net/api/sys/user"
        header= {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url, headers=header, json=data)
        return resp

    # 定义查询员工的接口
    @classmethod
    def query_emp_api(cls,emp_id,token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" +emp_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return resp

    # 定义修改员工的接口
    @classmethod
    def modify_emp_api(cls,emp_id,token,data):
        url = "http://ihrm-test.itheima.net/api/sys/user/" +emp_id
        header = {"Content-Type": "application/json",
                             "Authorization":token}
        resp = requests.put(url=url, headers=header, json=data)
        print(resp)

    # 定义删除员工的接口
    @classmethod
    def del_emp_api(cls,emp_id,token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        print(resp)
